/**
 * Copyright (c) 2024,  科泰集团教研团队
 * 版权所有，请勿侵权
 */
package com.ktjiaoyu.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Date;
import java.io.Serializable;
import java.util.Locale;

/**
 * @author 科泰集团教研团队
 * @version 1.0.0
 * @packageName com.ktjiaoyu.entity;
 * @fileName Page.java
 * @createTime 2024/10/01 13:00:57
 * @lastModify 2024/10/01 13:00:57
 */
public class SysUser implements Serializable {

  private Long id;  //主键ID
  private String account;  //账号
  private String realName;  //真实姓名
  //    @JSONField(serialize = false)  //序列化时不显示该字段
  private String password;  //密码
  private Integer sex;  //性别（1:女、2:男）
  //    @JSONField(format = "yyyy-MM-dd")  //序列化时显示为字符串格式
//    @DateTimeFormat(pattern = "yyyy-MM-dd")  //前端提交为字符串 需要转换为Date类型才能赋值
  private Date birthday;  //出生日期（年-月-日）
  private String phone;  //手机号码
  private String address;  //用户地址
  private Long roleId;  //用户角色id
  private Long createdUserId;  //创建人
  private Date createdTime;  //创建时间
  private Long updatedUserId;  //修改人
  private Date updatedTime;  //修改时间
  private Integer age; //年龄
  private String idPicPath; //证件照
  private String workPicPath; //工作照

  public String getIdPicPath() {
    return idPicPath;
  }

  public void setIdPicPath(String idPicPath) {
    this.idPicPath = idPicPath;
  }

  public String getWorkPicPath() {
    return workPicPath;
  }

  public void setWorkPicPath(String workPicPath) {
    this.workPicPath = workPicPath;
  }

  public Integer getAge() {
    if (this.birthday == null) {
      return 0;
    }
    //根据生日计算年龄使用LocalDate和Period实现
    LocalDate localeData = birthday.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    LocalDate now = LocalDate.now();
    return Period.between(localeData, now).getYears();
  }

  public void setAge(Integer age) {
    this.age = age;
  }

  // 当前用户角色，须通过关联查询
  private SysRole role;


  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }


  public String getAccount() {
    return account;
  }

  public void setAccount(String account) {
    this.account = account;
  }


  public String getRealName() {
    return realName;
  }

  public void setRealName(String realName) {
    this.realName = realName;
  }


  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }


  public Integer getSex() {
    return sex;
  }

  public void setSex(Integer sex) {
    this.sex = sex;
  }


  public Date getBirthday() {
    return birthday;
  }

  public void setBirthday(Date birthday) {
    this.birthday = birthday;
  }


  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }


  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }


  public Long getRoleId() {
    return roleId;
  }

  public void setRoleId(Long roleId) {
    this.roleId = roleId;
  }


  public Long getCreatedUserId() {
    return createdUserId;
  }

  public void setCreatedUserId(Long createdUserId) {
    this.createdUserId = createdUserId;
  }


  public Date getCreatedTime() {
    return createdTime;
  }

  public void setCreatedTime(Date createdTime) {
    this.createdTime = createdTime;
  }


  public Long getUpdatedUserId() {
    return updatedUserId;
  }

  public void setUpdatedUserId(Long updatedUserId) {
    this.updatedUserId = updatedUserId;
  }


  public Date getUpdatedTime() {
    return updatedTime;
  }

  public void setUpdatedTime(Date updatedTime) {
    this.updatedTime = updatedTime;
  }

  public SysRole getRole() {
    return role;
  }

  public void setRole(SysRole role) {
    this.role = role;
  }
}